package base.Day05.Exercise;
import java.util.Arrays;
import java.util.Random;

public class StandardExercise
{
    public static void main(String[] args)
    {
        StandardExercise standardExercise = new StandardExercise();
        standardExercise.arrExercise();
        System.out.println("----------------------------");
        standardExercise.arrExercise1();
        System.out.println("------------------------");
        standardExercise.generateArray(3,11);

    }


    void arrExercise()
    {
        int[] arr = new int[3];
        for (int i = 0; i < arr.length; i++)
        {
            // 100-200
            arr[i] = new Random().nextInt(101) + 100;
        }
        // 扩容
        arr = Arrays.copyOf(arr, 6);
        for (int j :
                arr)
        {
            System.out.println(j);
        }
    }

    void arrExercise1()
    {
        double[] arr = new double[4];
        for (int i = 0; i < arr.length; i++)
        {
            arr[i] = new Random().nextDouble() * 100;
            System.out.println(arr[i]);

        }
        arr = Arrays.copyOf(arr, 6);

        for (double j : arr)
        {
            System.out.println(j);
        }
    }


    void maxOfArray(int[] arr)
    {
        int max = arr[0];
        for (int i = 0; i < arr.length; i++)
        {
            max = (max > arr[i] ? max : arr[i]);
        }
        System.out.println("max = " + max);
    }


    void maxOfArray1(int[] arr)
    {
        int max = arr[0];
        for (int i : arr)
        {
            if (i > max)
            {
                i = max;
            }
        }
        System.out.println("max = " + max);
    }


    void say()
    {
        System.out.println("大家 看我看我 我是个SB 没毛病啊");
    }

    void say1()
    {
        System.out.println("ha ha ha ha ha ha");
    }

    void say(int x)
    {
        System.out.println("there is a function with a argument");   // argument parameter  parameter parameter arguments arguments arguments arguments
    }

    void say2(int x)
    {
        System.out.println("there is a function with a argument");
    }

    void say3(String content, int count)
    {
        if (count > 10)
            return;
        System.out.println("hahahah");
    }

    void say33(String content, int count)
    {
        if (count > 11)
            return;
        System.out.println(content);
    }


    int sum(int num1, int num2)
    {
        return num1 + num2;
    }

    int sum1(int num1, int num2)
    {
        return num1+num2;
    }

    int[] generateArray(int len,int max)
    {
        int[] arr = new int[len];
        for (int j : arr)
        {
            //
            j = new Random().nextInt(max);
        }
        return arr;
    }


    int[] generateArray1(int len,int max)
    {
        int[] arr = new int[len];
        for (int i : arr)
        {
            // 300-500
            i = new Random().nextInt(max)+300;
        }
        return arr;
    }

}
